<#include "common/header.html"/>

    <div class="wrapper wrapper-content animated fadeInUp">
        <div class="row">
            <div class="col-sm-12">

                <div class="ibox">
                    <div class="ibox-title">
                        <h5>商品列表</h5>
                        <div class="ibox-tools">
                            <a href="/product/toadd" class="btn btn-primary btn-xs">添加用户</a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="row m-b-sm m-t-sm">
                           
                            <div class="col-md-12">
                               <form role="form" action="list" class="form-inline">
                            <div class="form-group">
                                <label for="exampleInputEmail2" >商品名称</label>
                                <input type="text" name="proName" placeholder="请输入商品名称" id="exampleInputEmail2" class="form-control">
                            </div>
                            <button class="btn btn-primary" type="submit">搜索</button>
                        </form>
                            </div>
                        </div>

                        <div class="project-list">

                            <table class="table table-hover">
                                <tbody>
                                	<tr>
                                		<th>序号</th>
                                		<th width="45%">商品名称</th>
                                		<th>商品价格</th>
                                		<th>商品数量</th>
                                		<th width="15%">操作</th>
                                	</tr>
                                    <#list pageInfo.records as pro>
                                    <tr>
                                    	<td>${pro_index + 1}</td>
										<td>${pro.proName}</td>
										<td>${pro.proPrice}</td>
										<td>${pro.proNum}</td>
                                        <td>
                                            <a href="get?id=${user.id}" class="btn btn-white btn-sm"><i class="fa fa-folder"></i> 查看 </a>
                                            <a href="del/${pro.id}" class="btn btn-white btn-sm del"><i class="fa fa-pencil"></i> 删除 </a>
                                        </td>
                                    </tr>
                                    <#else>
                                    		<tr>
                                    			<td colspan="4">无结果</td>
                                    		</tr>
                                    </#list>
                                    </tbody>
                                </table>
                                <nav aria-label="Page navigation">
								  <ul class="pagination">
								  
								  <#if pageInfo.hasPrevious() >
								   <li>
								      <a href="list?pageno=1">
								        <span aria-hidden="true">首页</span>
								      </a>
								    </li>
								    <li>
								      <a href="list?pageno=${pageInfo.current - 1}">
								        <span aria-hidden="true">上一页</span>
								      </a>
								    </li>
								    </#if>
								    <#if pageInfo.hasNext() >
								    <li>
								      <a href="list?pageno=${pageInfo.current + 1}">
								        <span aria-hidden="true">下一页</span>
								      </a>
								    </li>
								    <li>
								      <a href="list?pageno=${pageInfo.pages}">
								        <span aria-hidden="true">末页</span>
								      </a>
								    </li>
								     
								    </#if>
								    <li>
								     	<a>${pageInfo.current}/${pageInfo.pages}</a>
								    </li>
								  </ul>
								</nav>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
	<#include "common/footer.html"/>
	<script>
		$(function(){
			$(".del").click(function(){
				var that = $(this);
				//get post ajax error
				$.ajax({
					url:that.attr("href"),
					dataType:"json",
					success:function(f){
						if(f){
							parent.layer.alert('删除成功')
							that.closest("tr").remove();
						}else{
							parent.layer.alert('删除失败')
						}
					},
					error:function(data){
						if(data.status == 401){
							parent.layer.alert('没有权限操作')
						}
					}
				})
				return false;
			})
		})
	
	</script>
